<template>
    <div>
        <h1>首页</h1>
        <p>首页段落</p>
        <router-link to="/home/news">新闻</router-link>   
        <router-link to="/home/message">消息</router-link>
        <router-view></router-view>
    </div>
</template>

<script>
export default {
    name: "Home",
    data() {
        return {path: '/home/news'} 
    },
    created(){
        console.log("home create");
        // document.title = "首页"
    },
    destroyed(){
        console.log("home destroy");
    },
    activated(){ // 使用keep-alive时才使用
        console.log("actived");
        // console.log(this.path);
        this.$router.push(this.path)
    },
    beforeRouteLeave(to, from, next) {
        this.path = this.$route.path
        next()
    }
}
</script>

<style>

</style>